//FileW2B.java 
package com.SkyAI.test.file;  

/**
 * 从指定文件中读取金山背单词的生词，转换成我爱背单词的词库，中间存在字符格式转换等处理内容
 * @author ZhouMQ
 * 
 */

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class FileW2B {

	/**入参第一个为读取的文件名，第二个入参为写的文件名，如果没有为按默认值
	 * 
	 * @param args
	 */
	public static void main( String[] args ){
		String inFileName = "D:\\tmp\\我的生词本.txt";
		String outFileName = "D:\\tmp\\newWord.txt";
		
		if ( args.length > 0 )
			inFileName = args[0];
		if ( args.length > 1 )
			outFileName = args[1];
		
		FileW2B w2b = new FileW2B();
		try{
			w2b.ReadFileByLine(inFileName, outFileName);
		}catch(Exception ex){
			//TODO
		}
	}
	
	
	/**从文件中读取一行数据并转编码
	 * 
	 * 
	 * @param sFileName
	 * @return
	 * @throws FileNotFoundException
	 */
	
	int ReadFileByLine(String inFileName, String outFileName) throws FileNotFoundException{
		File file = new File(inFileName);
		BufferedReader reader = new BufferedReader(new FileReader(file)); 
		
		try {

			String sReadBuff;
			while( (sReadBuff = reader.readLine()) != null ){
				
				WriteFilebyLine(outFileName, sReadBuff);
			}
			reader.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 0;
	}
	
	/** 写入数据到指定文件
	 * 
	 * @param sFileName 写入的文件名称
	 * @param sTmp 需写入的内容
	 * @return
	 */
	
	int WriteFilebyLine(String sFileName, String sTmp){
		File file = new File(sFileName);
		
		return 0;
	}
}
